hts=httpserver
cc=c++
LD_FLAGS=-std=c++11 -lpthread
src=main.cc
src2=ProtocolFunc.cpp
curr=$(shell pwd)

.PHONY:all
all:$(hts) CGI

$(hts):$(src)  $(src2) 
	$(cc) -o $@ $^ $(LD_FLAGS)


CGI:
	cd $(curr)/cgi; make; cd -;

.PHONY:clean
clean:
	rm -rf $(hts)
	rm -rf output
	cd $(curr)/cgi; make clean; cd -;

.PHONY:output
output:
	mkdir -p output
	cp -rf $(hts) output/
	cp -rf ./wwwroot output/
	cp ./cgi/cgi_main output/wwwroot/